﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xts
{
    namespace IceRuntime
    {
        public class XStormPublisher : XStormBase
        {
            public XStormPublisher(ref Ice.Communicator ic, ref Ice.Logger logger)
                :base(ref ic, ref logger)
            {
            }

            public bool RetrievePublishPrx(string topicName, out Ice.ObjectPrx publisherPrx)
            {
                publisherPrx = null;
                IceStorm.TopicPrx topicPrx = RetrieveTopic(topicName);                

                if (topicPrx == null)
                {
                    x_logger.error("Failed to retrieve topic:" + topicName);
                    return false;
                }

                try
                {
                    publisherPrx = topicPrx.getPublisher();
                    return true;
                }
                catch (Ice.Exception ex)
                {
                    x_logger.error(ex.Message);
                }
                return false;
            }
        }
    }
}
